<?php 
session_start(); 
if(!isset($_SESSION['install'])) 
  {
    header('Location: ../');
  }

$CONF['langue'] = $_SESSION['langue'];
include('../php/langue.php');

$m = '';

if(!empty($_POST['login']) && strlen($_POST['login']) > 3 && strlen($_POST['login']) < 20 && 
   !empty($_POST['password']) && strlen($_POST['password']) > 5 && strlen($_POST['password']) < 37 &&
   !empty($_POST['password2']) && strlen($_POST['password2']) > 5 && strlen($_POST['password2']) < 37 &&
   !empty($_POST['mail']) &&
   !empty($_POST['nom']) &&
   !empty($_POST['prenom']))
  {
    
    require_once '../php/fonctions.php';
    $nofonctions = true;
    require '../config_.php';
    require '../php/SQL.php';
    
    if($_POST['password'] != $_POST['password2'])
      {
	$m = $LANG[31];
      }
    elseif(strlen($_POST['password']) < 6)
      {
	$m = $LANG[32];
      }
    else
      {
	$sql = SQL::GetInstance();
	$sql->enregistrerUtilisateur('visitor', '-----', '-----', '-----', '-----',0,0,1, $CONF['sql_prefix']);
	  
	if(!$sql->enregistrerUtilisateur($_POST['login'], $_POST['password'], $_POST['prenom'], $_POST['nom'], $_POST['mail'],1,1,1, $CONF['sql_prefix']))
	  {
	    $m = $LANG[33];
	  }
	else
	  {
	    include('top.php');
	    echo '<h1>'.$LANG[39].'</h1>';
	    echo $LANG[34].$_POST['login'].$LANG[35].'<br />';
	    echo $LANG[36].'<a href="../admin.php">'.$LANG[37].'</a>.';
        echo '<p style="color:red">'.$LANG[88].'</p>';
	    include('bottom.php');

	    exit(0);
	    // ok + exit 
	  }
      }
  }

include('top.php');

?>
<h1><?php echo $LANG[39]; ?></h1>
<blockquote class="info">
<form action="step-4.php" method="post">
<p>
[beta] Veuillez remplir tous les champs, et assurez vous que les password soient les mêmes (avec plus de 5 carractères)
</p>
<label for="b1">
  <?php echo $LANG[40]; ?><br /><input id="b1" type="text" name="login" value="admin" /><br />
</label>
<label for="b2">
  <?php echo $LANG[41]; ?><br /><input id="b2" type="password" name="password" value="" /><br />
</label>
<label for="b3">
  <?php echo $LANG[42]; ?><br /><input id="b3" type="password" name="password2" value="" /><br />
</label>
<label for="b4">
  <?php echo $LANG[43]; ?><br /><input id="b4" type="text" name="nom" value="" /><br />
</label>
<label for="b5">
  <?php echo $LANG[44]; ?><br /><input id="b5" type="text" name="prenom" value="" /><br />
</label>
<label for="b6">
  <?php echo $LANG[441]; ?><br /><input id="b6" type="text" name="mail" value="" /><br />
</label>
<input type="submit" value="<?php echo $LANG[45]; ?>" />
</form>
</blockquote>
<?php
  if(!empty($m)) echo '<blockquote class="error">'.$m.'</blockquote>';
  include('bottom.php');
?>
